package titt.io.encoding.stringable;

import titt.io.encoding.Decoder;
import titt.type.Type;
import titt.util.Bytes;

public class StringFromBytesDecoder implements StringDecoder {
	
	private final Decoder d;
	
	public StringFromBytesDecoder(Decoder d) {
		this.d = d;
	}
	
	@Override
	public Object decodeFromString(Type t, String enc) {
		return d.decode(t, Bytes.asBytes(enc));
	}

	@Override
	public boolean isStringDecodeable(Type t) {
		return d.isDecodeable(t);
	}

	@Override
	public Object decode(Type t, byte[] b) {
		return d.decode(t, b);
	}

	@Override
	public boolean isDecodeable(Type t) {
		return d.isDecodeable(t);
	}

}
